package com.hyl.convert;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description TODO
 * @Author com.hyl
 * @Date 2022/10/15 11:07
 **/
public class StringToDateConvert implements Converter<String, Date> {

	private String datePattern;

	@Override
	public Date convert(String s) {
		try {
			return  new SimpleDateFormat(datePattern).parse(s);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}

	public String getDatePattern() {
		return datePattern;
	}

	public void setDatePattern(String datePattern) {
		this.datePattern = datePattern;
	}
}
